package two;
public class PrototypeTest {
    public static void main(String[] args) {
        try {
            // 创建原始的结业证书对象
            StudentId studentId = new StudentId("20240001"); // 学号
            Certificate originalCertificate = new Certificate("张三", "沧州师范", studentId);

            // 测试浅克隆
            Certificate shallowClonedCertificate = originalCertificate.clone();
            shallowClonedCertificate.setStudentName("李四");
            shallowClonedCertificate.getStudentId().setId("20240002"); // 改变学号

            System.out.println("=== 浅克隆结果 ===");
            System.out.println("原始证书:");
            originalCertificate.printCertificate();
            System.out.println("浅克隆证书:");
            shallowClonedCertificate.printCertificate();

            // 测试深克隆
            Certificate deepClonedCertificate = originalCertificate.deepClone();
            deepClonedCertificate.setStudentName("王五");
            deepClonedCertificate.getStudentId().setId("20240003"); // 改变学号

            System.out.println("=== 深克隆结果 ===");

            System.out.println("原始证书:");
            originalCertificate.printCertificate();
            System.out.println("深克隆证书:");
            deepClonedCertificate.printCertificate();

        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    }
}

